package com.techsen.tsweb.sys.web.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.techsen.tsweb.core.domain.JsonResult;
import com.techsen.tsweb.sys.domain.Post;
import com.techsen.tsweb.sys.service.PostService;

@Controller
@RequestMapping("/sys/post")
public class PostController {
    
    @Resource
    private PostService postService;
    
    /**
     * 查看职位
     */
    @RequestMapping("/orgid/{orgId}")
    public String view(@PathVariable("orgId") String orgId, Model model) {
        Post post = this.postService.getOneByEntity(new Post().setOrgId(orgId));
        model.addAttribute("post", post);
        return "sys/post-view";
    }
    
    /**
     * 修改职位
     */
    @RequestMapping("/update")
    public @ResponseBody JsonResult update(Post post) {
        this.postService.update(post);
        return new JsonResult(post);
    }

}
